/**
 * Student.java
 * com.book.test
 * Copyright (c) 2013, 公司版权所有.
 */

package com.book.test;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;

/** 
 * @author 潘吉友
 * @Date 2013-2-28
 */
public class Student {

	private int id;

	private String name;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Student() {

		// TODO Auto-generated constructor stub

	}

	public Student(int id, String name) {
		this.id = id;
		this.name = name;
	}

	/**
	 * TODO测试用的类
	 * @param args
	 */

	@SuppressWarnings("unused")
	public static void main(String[] args) {
		try {
			File file = new File("C:\\Users\\TechKno001\\Desktop\\aa.zip");  
			InputStream in = null; 
			if(!file.exists())
                    throw new Exception("文件不存在！");
			System.out.println("以字节为单位读取文件内容，一次读一个字节：");  
			// 一次读一个字节   
			in = new FileInputStream(file);  
			int tempbyte;  
			while((tempbyte=in.read()) != -1){  
			System.out.write(tempbyte);  
			}  
			in.close();  
			String path = "src/downnote";
			StringBuilder filename = new StringBuilder();
			
			filename.append(128).append("_")
					.append(3536).append(".zip");
			System.out.println(path + "/" + filename.toString());
			  File outfile = new File(path + "/" + filename.toString());
	            if(!outfile.exists())
	                if(!outfile.createNewFile())
	                    throw new Exception("文件不存在，创建失败！");

			FileOutputStream fs = new FileOutputStream(outfile);
			byte[] buffer = new byte[1024 * 1024];
			int bytesum = 0;
			int byteread = 0;
			InputStream stream = new FileInputStream(file);
			while ((byteread = stream.read(buffer)) != -1) {
				bytesum += byteread;
				fs.write(buffer, 0, byteread);
				fs.flush();
			}
			fs.close();
			stream.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

